Restore attribute to current module from a basline

Hello,

I was wondering what wound be the best way of restoring an attribute and its value to the current module from a baseline module. The attribute was deleted from the current module? Does anyone have code they be willing to share. Thank you.

-Jim
SystemAdmin - Wed Sep 19 10:15:34 EDT 2012

Re: Restore attribute to current module from a basline
SystemAdmin - Thu Sep 20 00:41:16 EDT 2012

A possible process that does not require DXL could be to redefine the attribute, then use export and import to rebuild the attribute values in the current module. An instruction outline would be something like the following:

Redefine the attribute in the current module exactly as it is defined in the baseline version - attribute name must be exactly the same.

Create a view in the baseline version that only shows the DOORS "Object Identifier" attribute and the attribute that you want to export to the current version.

Make sure that no filters are enabled and that Deleted objects are not showing.

Make sure that the column titles display the actual names of the underlying attributes.

Export the view to Excel via the File->Export->Microsoft Office->Excel menu, then save the Excel file in a comma seperated variable (csv) file format.

Import the csv file into the current module using the File->Import->Spreadsheet menu. The radio button options should be set to "By Column labels", Update Existing objects", "All objects"

Browse for the csv file and select this as the Input File

Select the Import button, choose the "Object Identifier" attribute as the unique import key.

If DOORS raises a prompt that some objects were created after the import, then this suggests that the baseline version has some objects that are not in the current version (filter\look for objects where Object Text and Object Heading are empty). The current module could also have objects that are not in the baseline version (not easy to find these, perhaps filter\look for objects where where the value of the attribute that was being rebuilt is empty and confirm if they should have been empty, I'm sure there is a better way).

It's recommended that you create a copy of the module and rehearse this first.


Paul Miller,
Melbourne, Australia

Re: Restore attribute to current module from a basline
Mathias Mamsch - Thu Sep 20 04:52:46 EDT 2012

SystemAdmin - Thu Sep 20 00:41:16 EDT 2012
A possible process that does not require DXL could be to redefine the attribute, then use export and import to rebuild the attribute values in the current module. An instruction outline would be something like the following:

Redefine the attribute in the current module exactly as it is defined in the baseline version - attribute name must be exactly the same.

Create a view in the baseline version that only shows the DOORS "Object Identifier" attribute and the attribute that you want to export to the current version.

Make sure that no filters are enabled and that Deleted objects are not showing.

Make sure that the column titles display the actual names of the underlying attributes.

Export the view to Excel via the File->Export->Microsoft Office->Excel menu, then save the Excel file in a comma seperated variable (csv) file format.

Import the csv file into the current module using the File->Import->Spreadsheet menu. The radio button options should be set to "By Column labels", Update Existing objects", "All objects"

Browse for the csv file and select this as the Input File

Select the Import button, choose the "Object Identifier" attribute as the unique import key.

If DOORS raises a prompt that some objects were created after the import, then this suggests that the baseline version has some objects that are not in the current version (filter\look for objects where Object Text and Object Heading are empty). The current module could also have objects that are not in the baseline version (not easy to find these, perhaps filter\look for objects where where the value of the attribute that was being rebuilt is empty and confirm if they should have been empty, I'm sure there is a better way).

It's recommended that you create a copy of the module and rehearse this first.


Paul Miller,
Melbourne, Australia

Be careful with purged objects though. The spreadsheet import will create those objects again, immediately after the last updated object. The importer will tell you how many objects he created and if it is more than 0 you might want to either search for those objects and delete them (e.g. created on = today, created by = you) or not save. If you want to get rid of those objects before you import them, export the identifiers of the current version to a different excel sheet and use MATCH/INDEX to find the ones in the other excel sheet that do not exist in the current version sheet. Maybe this helps, regards, Mathias

Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: Restore attribute to current module from a basline
SystemAdmin - Thu Sep 20 08:38:10 EDT 2012

Mathias Mamsch - Thu Sep 20 04:52:46 EDT 2012
Be careful with purged objects though. The spreadsheet import will create those objects again, immediately after the last updated object. The importer will tell you how many objects he created and if it is more than 0 you might want to either search for those objects and delete them (e.g. created on = today, created by = you) or not save. If you want to get rid of those objects before you import them, export the identifiers of the current version to a different excel sheet and use MATCH/INDEX to find the ones in the other excel sheet that do not exist in the current version sheet. Maybe this helps, regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Hello,

Thank you for the reply. After posting my question I found a script within "Kitchen" are there any issues related to this script.

Thank you,
-Jim

Re: Restore attribute to current module from a basline
Mathias Mamsch - Thu Sep 20 09:20:40 EDT 2012

SystemAdmin - Thu Sep 20 08:38:10 EDT 2012
Hello,

Thank you for the reply. After posting my question I found a script within "Kitchen" are there any issues related to this script.

Thank you,
-Jim

:-) I would not trust ANY kitchen script. By the way implementing this yourself is very easy. Just to give some hints. Copying the attribute definition is very easy:

string sAttrName = "MyAttribute"
// copyops.inc defines 'copyAttrDefRename_ (AttrDef adSrc, Module modSrc, Module modTgt, string sNewName) 
 
// load the baseline
Module modBaseline = load (...) 
 
Module modTgt = current 
if (!isEdit modTgt || ! canCreate modTgt) { ... }
 
AttrDef adSrc = find(modBaseline, sAttrName) 
if (null adSrc) { /* inform user about missing attribute */ }
 
AttrDef adTgt = find (modTgt, sAttrName) 
if (!null adTgt) { /* inform user that attribute exists, and ask if he wants to overwrite */ 
} else {
   copyAttrDefRename_ (adSrc, modBaseline, modTgt, sAttrName)
}

And once the attribute exists copying over the values is a piece of cake:

Skip skSrc = create() 
 
// cache the baseline objects for speed!
Object o; 
for o in entire modBaseline do {
  int nr = o."Absolute Number" 
  put (skSrc, nr, o) 
}
 
// now copy the values
for o in entire modTgt do {
  int nr = o."Absolute Number" 
  Object oBase = null
  if (find(skSrc, nr, oBase)) {
     if (isDeleted o) { 
        /* want to undelete the object before setting the value for DOORS 9 
           or just Skip that value
        */
        continue
     }
     if (!canWrite (o.sAttrName)) { ... }
     // copy the attribute value 
     set (o.sAttrName, oBase.sAttrName)
 
     // copy doors pictures? 
     if (sAttrName == "Object Text") {
     // insert copy picture code, if you want to copy DOORS picture objects 
     }
  }
}

It should be that easy. I did not test the code, so typos, etc. are intended. Maybe this helps, regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS